<? 
	include('base.php');
	User::protect();
	include_class('tours');
	$section = 'tours';
	if ($_POST['submit']) { 
		// add news entry
		$tour = Tour::add($_POST);
		if (!db::isError($tour)) {
			header('Location: tour_edit.php?id=' . $tour->getID());
		}
	}	
	
	$page_title = 'Add Tour';
	$calendar = true;
	$editors = array('description');
	include('layout/header.php');
?>

<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>
	<a href="live.php">Live &#62;</a>
	<a href="tours.php">Tours &#62;</a>
</div>

<? 

if (User::isAdmin()) { 

	if (db::isError($tour)) {
		$tour->outputList();
	} ?>
		<h1>new entry:</h1>
		<div class="inset">
		<form id="edit_entry" action="<?=$PHP_SELF?>" method="post">
		<table border="0" class="edit-form" cellspacing="0" cellpadding="0">
		<tr>
			<td width="50%"><strong>Start Date (<a style="vertical-align: middle" href="javascript:void(0)" onclick="popUpCalendar(this, document.getElementById('start_date'), '<?=DATE_JS_CALENDAR?>')">Calendar</a>)</strong><br/>
			<input type="text" name="start_date" class="text" id="start_date" value="<?=$_POST['start_date']?>"></td>
			<td width="50%"><strong>End Date (<a style="vertical-align: middle" href="javascript:void(0)" onclick="popUpCalendar(this, document.getElementById('end_date'), '<?=DATE_JS_CALENDAR?>')">Calendar</a>)</strong><br/>
			<input type="text" name="end_date" class="text" id="end_date" value="<?=$_POST['end_date']?>"></td>
		</tr>
		</table>
		<div class="edit-form">
			<strong>Title</strong><br/>
			<input type="text" name="title" class="text" value="<?=$_POST['title']?>">
		</div>
		<div class="edit-form">
		<strong>Description:</strong><br/>
		<textarea name="description" class="full" id="description"><?=$_POST['description']?></textarea>
		</div>	
		
		<div class="edit-form">
			<input type="submit" value="Add Tour" class="button" name="submit">
			<input type="submit" value="Exit Without Adding" class="button" name="preview" onclick="location.href='tours.php'; return false">
		</div>
		</div>
<? } else {
	Error::outputDialog('Return to Tours', 'tours.php', 'Only an administrator may create tours.');
} ?>

<? include('layout/footer.php'); ?>
